import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;

import javax.swing.BorderFactory;
import javax.swing.JLabel;


public class ChunkPreview extends JLabel {

	Image image;
	
	public ChunkPreview()
	{				
		image=null;
		setPreferredSize(new Dimension(128,128));
		setBackground(Color.white);
		
	}
	
	
	public void paint(Graphics g)
	{
		g.setColor(Color.white);
		g.fillRect(0, 0, 128, 128);
		if(image==null)
		{
			g.setColor(Color.black);
			g.drawString("No chunk loaded!",0,64);
			return;
		}
		
		g.drawImage(image, 0, 0, null);
	
		g.setColor(Color.red);
		g.drawRect(42, 42, 42, 42);
	}
	
	public void setImage(BufferedImage img)
	{
		if(img!=null)
			image=img.getScaledInstance(128, 128, BufferedImage.SCALE_FAST);
		else image=null;
	}
	
	public Dimension getPreferredSize()
	{		
		return new Dimension(128,128);
	}
}
